/**
 * Created by XQ on 2017/4/30.
 */
app.config(['$provide',function($provide) {
    $provide.factory('getUserAccountService',['$http',function ($http) {
        var user = {};//定义一个Object对象'

        var account;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        user.setAccount = function (newAccount) {
            account = newAccount;
        }
        user.getAccount = function () {
            return account;
        }
        return user;//返回这个Object对象
    }])
    $provide.factory('getExchangeId',function () {
        var exchangeContent = {};//定义一个Object对象'

        var Id;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        exchangeContent.setId = function (newId) {
            Id = newId;
        }
        exchangeContent.getId = function () {
            return Id;
        }
        return exchangeContent;//返回这个Object对象
    })
    $provide.factory('getActivityId',function () {
        var ActivityContent = {};//定义一个Object对象'

        var Id;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        ActivityContent.setActId = function (newId) {
            Id = newId;
        }
        ActivityContent.getActId = function () {
            return Id;
        }
        return ActivityContent;//返回这个Object对象
    })

    $provide.factory('getResult',function ($http,$q) {
        function get(url) {
            var deferred=$q.defer();
            var promise=deferred.promise;
            $http.get(url).then(function (resp) {
                if (resp.data.code == 0){
                    deferred.resolve(resp.data.data)
                }else {
                    deferred.resolve("0")
                }
            })
            return promise;
        }
        return {
            get: get
        }
    })
    $provide.factory('getSchool',function ($http) {
        var school = {};//定义一个Object对象'

        var name;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        school.setSchName = function (newName) {
            name = newName;
        }
        school.getSchName = function () {
            return name;
        }
        return school;//返回这个Object对象
    })
    $provide.factory('IsTrue',function ($http) {
        var myObj = {};//定义一个Object对象'

        var myAttr;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        myObj.setMyAttr = function (newMyAttr) {
            myAttr = newMyAttr;
        }
        myObj.getMyAttr = function () {
            return myAttr;
        }
        return myObj;//返回这个Object对象
    })
    $provide.factory('countAdd',function ($http) {
        var countAddObj = {};//定义一个Object对象'

        var countAddAttr = 0;//定义一个私有化的变量
        //对私有属性写getter和setter方法
        countAddObj.setMyCount = function () {
            countAddAttr = countAddAttr+1;
        }
        countAddObj.getMyCount = function () {
            return countAddAttr;
        }
        return countAddObj;//返回这个Object对象
    })

}]);